<div class="content">
    <div class="tl-img"><a class="<?php echo $this->controller; ?>"></a></div>
    <h1>Galeria de Fotos</h1>
    <div class="texto">
        <div id="container">
    <?php 
    $arr_img = array();
    foreach ($this->result as $row) {

        $src = $row->GAL_NOM;
        
        $tam_img = getimagesize($src);

        if($tam_img[0] == '196') {
            $tam ='';
            $tamimg ='196';
        }
        else{
            $tam = 'w2';
            $tamimg ='394';
        }

        $id = $row->GAL_ID;
        $arr_img[$id] = $id;
        
        //echo '<img class="item" width="'.$tamimg.'" height="'.$tamimg.'" src="'.$this->urlbase.'/'.$src.'" />';
        echo '<div class="item '.$tam.'"><a href="'.$this->urlbase.'/'.str_replace('_tb.', '.',$src).'" data-lightbox="roadtrip" /><img width="'.$tamimg.'" height="'.$tamimg.'"  src="'.$this->urlbase.'/'.$src.'" /></a></div>';
        
           
        
    }
    
    $imgs = glob('public/upload/'.$this->controller.'/*_tb.*');
    asort($imgs);
    foreach ($imgs as $key => $src) {    
        
        $tam_img = getimagesize($src);

        if($tam_img[0] == '196') {
            $tam ='';
            $tamimg ='196';
        }
        else{
            $tam = 'w2';
            $tamimg ='394';
        }

        $nome = end(explode('/', $src));
        $nome = explode('.', $nome);
        $id = str_replace('_tb', '',$nome[0]);
        
        if(!isset($arr_img[$id])){
            //echo '<img class="item" width="'.$tamimg.'" height="'.$tamimg.'" src="'.$this->urlbase.'/'.$src.'" />';
            echo '<div class="item '.$tam.'"><a href="'.$this->urlbase.'/'.str_replace('_tb.', '.',$src).'" data-lightbox="roadtrip" /><img width="'.$tamimg.'" height="'.$tamimg.'"  src="'.$this->urlbase.'/'.$src.'" /></a></div>';
        }
           
        
    }
    ?>
        </div>
    </div>    
</div>

<script src="<?php echo $this->urlbase.'/public/media/js/masonry.pkgd.min.js'?>"></script>
<script> 
$(function(){
    
    var container = document.querySelector('#container');
    var msnry = new Masonry( container, {
      // options
      itemSelector: '.item',
      columnWidth: 1
    });
 
  
}); 
</script>
<script>
var linkfacebook = 'http://www.seusite.com.br';
 
function curtirFoto(){
    var url = encodeURIComponent("<?php echo $_SERVER['SERVER_NAME']."/"; ?>"+$('.lb-image').attr('src'));
    window.open('http://www.facebook.com/sharer.php?u='+url+'','ventanacompartir', 'toolbar=0, status=0, width=650, height=450');
}

</script>
<link  href="<?php echo $this->urlbase.'/public/media/js/lightbox/css/lightbox.css' ?>" rel="stylesheet" media="screen"/>
<script src="<?php echo $this->urlbase.'/public/media/js/lightbox/js/modernizr.custom.js' ?>"></script>
<script src="<?php echo $this->urlbase.'/public/media/js/lightbox/js/lightbox-2.6.min.js' ?>"></script>
 